package main;

import java.util.Scanner;

import static test.NGuessNumber.compareGuessAnswer;
import static test.NGuessNumber.generateAnswer;
import static test.NGuessNumber.getPlayerInput;

public class Main {
    public static void main(String[] args) {
        String against = "";
        Scanner sc = new Scanner(System.in);

        do
        {
            System.out.println("欢迎玩新猜数字游戏, 请猜四个不重复的[0, 9]之间的整数, 非法的猜测数字默认用0代替");
            int[] answer = generateAnswer();

            while (true)
            {
                int[] guess = getPlayerInput();

                if (isWin(answer, guess))
                {
                    against = sc.next();
                    break;
                }
            }

        }
        while (against.equalsIgnoreCase("y"));


        sc.close();

    }
    public static boolean isWin(int[] answer, int[] guess)
    {
        int A = compareGuessAnswer(answer, guess)[0];
        if (A == 4)
        {
            return true;
        }
        return false;
    }
}
